/*
 * @Author: thl t15945324431@163.com
 * @Date: 2023-10-20 09:29:48
 * @LastEditors: thl t15945324431@163.com
 * @LastEditTime: 2023-11-30 16:02:18
 * @FilePath: \cw_web\gl\src\components\TheButton\index.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 * @desc 按钮组件
 * @props { string } type 按钮类型
 * @props { bool } loading  是否显示loading
 * @props { func } handler 点击按钮事件
 * @props { string } size 按钮大小
 */
import React from 'react'
import { Button } from 'antd';
import PropTypes from 'prop-types'
import { isContained } from '@/utils/tools'
import _connect from '@/_connect'
class TheButton extends React.Component {
    render() {
        let allPermi = this.props.idents
        const { children, haspermi } = this.props;
        return <Button
            style={{ ...this.props.otherStyle,'display': (haspermi && haspermi.length >= 0 && isContained(allPermi, haspermi)) ? '' : 'none', }}
            {...this.props}>
            {children}
        </Button>
        // if (auth) {
        //     if (React.$getFilterAuth(auth)) {
        //         return (
        //             <Button
        //                 {...this.props}>
        //                 {children}
        //             </Button>
        //         )
        //     } else {
        //         return ""
        //     }
        // } else {
        //     return <Button
        //         {...this.props}>
        //         {children}
        //     </Button>
        // }
    }
}

TheButton.propTypes = {
    loading: PropTypes.bool,
    type: PropTypes.string,
    size: PropTypes.string,
    color: PropTypes.string,
    danger: PropTypes.bool,
    haspermi: PropTypes.array
}
TheButton.defaultProps = {
    loading: false,
    type: 'link',
    size: 'small',
    color: '#1890ff',
    danger: false,
    haspermi: []
}
export default _connect(TheButton)
